<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>注册页面</title>
    <%@include file="/WEB-INF/pages/common/taglib.jsp" %>
    <%@include file="/WEB-INF/pages/common/common.jsp" %>
    <link href="${basePath}/singlewindows/css/base.css" rel="stylesheet" type="text/css"/>
    <link href="${basePath}/singlewindows/css/style.css" rel="stylesheet" type="text/css"/>
    <link href="${basePath}/resources/css/shouye.css" rel="stylesheet" type="text/css"/>
    <link href="${basePath}/resources/css/style.css" rel="stylesheet" type="text/css"/>
    <link href="${basePath}/resources/css/portal.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<%@include file="/WEB-INF/pages/common/header.jsp" %>
<div class="main-content-container">
    <div class="regist-main">
        <div class="regist-flowbar flowbar-step2"></div>
        <div class="regist-content">
            <div class="regist-userinfo-fillin">
                <form id="form_data">
                    <input type="hidden" name="registerSource" id="registerSource" value="8">
                    <input type="hidden" name="token" value="">
                    <!-- 是否从邮箱链接过来 -->
                    <input type="hidden" name="mailKey" id="mailKey"
                           value="${mailKey}">
                    <input type="hidden" name="mail" id="mail" value="${mail}">

                    <div class="clearfix regist-form-controller">
                        <label class="controller-label">注册邮箱</label>

                        <div class="controller-txt"><span class="txt-email">${mail}</span>
                        </div>
                    </div>
                    <div class="clearfix regist-form-controller">
                        <label class="controller-label"><span class="required">*</span>用户名</label>

                        <div class="controller-inp J-controllerInp">
                            <input type="text" name="username" placeholder="请输入登录用户名" class="inp-regist">
                        </div>
                    </div>
                    <div class="clearfix regist-form-controller">
                        <label class="controller-label"><span class="required">*</span>密码</label>

                        <div class="controller-inp J-controllerInp">
                            <input type="password" id="password" name="password" placeholder="请输入登录密码"
                                   class="inp-regist">
                        </div>
                    </div>
                    <div class="clearfix regist-form-controller">
                        <label class="controller-label"><span class="required">*</span>确认密码</label>

                        <div class="controller-inp J-controllerInp">
                            <input type="password" name="verityPassword" placeholder="请输入确认密码" class="inp-regist">
                        </div>
                    </div>
                    <div class="clearfix regist-form-controller">
                        <label class="controller-label"><span class="required">*</span>企业名称</label>

                        <div class="controller-inp">
                            <input type="text" name="orgName" placeholder="请输入企业营业执照上的企业名称" class="inp-regist">
                        </div>
                    </div>

                    <div class="clearfix regist-form-controller">
                        <label class="controller-label"><span class="required">*</span>机构代码</label>

                        <div class="controller-inp">
                            <input type="text" name="organizationId" placeholder="请输入社会信用代码或组织机构代码"
                                   class="inp-regist">
                        </div>
                    </div>

                    <div class="clearfix regist-form-controller">
                        <label class="controller-label"><span class="required">*</span>身份证号</label>

                        <div class="controller-inp">
                            <input type="text" name="idNo" placeholder="请输入15或18位身份证号码"
                                   class="inp-regist">
                        </div>
                    </div>

                    <div class="clearfix regist-form-controller">
                        <label class="controller-label">企业地址</label>

                        <div class="controller-inp">
                            <input type="text" name="address" placeholder="请输入企业办公所在地址" class="inp-regist">
                        </div>
                    </div>
                    <div class="clearfix regist-form-controller">
                        <label class="controller-label">联系人</label>

                        <div class="controller-inp">
                            <input type="text" name="contact" placeholder="请输入企业联系人" class="inp-regist">
                        </div>
                    </div>
                    <div class="clearfix regist-form-controller">
                        <label class="controller-label">联系方式</label>

                        <div class="controller-inp">
                            <input type="text" name="phone" placeholder="请输入企业联系方式（电话、手机）" class="inp-regist">
                        </div>
                    </div>
                    <div class="regist-form-submit">
                        <input type="submit" value="注　册" class="regist-submit-btn">
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
        $("#form_data").validate({
            debug: false, //false表示验证通过后不要自动提交表单
            onkeyup: false, //表示关闭按键松开时候监听验证
            rules: {
                username: {
                    required: true,
                    rangelength: [2, 20],
                    checkUsername: true
                },
                password: {
                    required: true,
                    rangelength: [6, 20]
                },
                verityPassword: {
                    equalTo: "#password"
                },
                orgName: {
                    required: true,
                    maxlength: 80
                },
                organizationId: {
                    required: true,
                    checkOrganizationId: true
                },
                idNo: {
                    required: true,
                    checkIdNo: true
                },
                address: {
                    maxlength: 80
                },
                contact: {
                    maxlength: 80
                },
                phone: {
                    maxlength: 12
                }
            },
            messages: { //自定义错误信息，默认为英文，除了在这里配置以为，还可以通过配置文件进行配置
                username: {
                    required: "请输入登录用户名",
                    rangelength: "用户名长度限制为2-20个字符"
                },
                password: {
                    required: "请输入登录密码",
                    rangelength: "密码长度限制为6-20个字符"
                },
                verityPassword: {
                    equalTo: "密码输入不一致！"
                },
                orgName: {
                    required: "请输入企业名称",
                    maxlength: "长度超过最大80个字符限制"
                },
                organizationId: {
                    required: "请输入社会信用代码或组织机构代码"
                },
                idNo: {
                    required: "请输入身份证号"
                },
                address: {
                    maxlength: "长度超过最大80个字符限制"
                },
                contact: {
                    maxlength: "长度超过最大80个字符限制"
                },
                phone: {
                    maxlength: "请输入正确的联系方式"
                }
            },
            //验证通过可以在这里做你想做的事情
            submitHandler: function (form) {
                form.submit();
            }
        });
    });

    jQuery.validator.addMethod("checkUsername", function (value) {
        var reg = /^[a-zA-Z][a-zA-Z0-9_]*$/;
        if (reg.test(value)) {
            return true;
        }
        return false;
    }, "用户名包含数字、字母和下划线,并以字母开头");

    jQuery.validator.addMethod("checkOrganizationId", function (value) {
        var reg = /^[A-Za-z0-9]{1,20}$/;
        if (reg.test(value)) {
            return true;
        }
        return false;
    }, "请输入正确的社会信用代码或组织机构代码");

    jQuery.validator.addMethod("checkIdNo", function (value) {
        var reg = /^[0-9]{15,18}$/;
        if (reg.test(value)) {
            return true;
        }
        return false;
    }, "请输入15或18位身份证号码");

    function registUser() {
        $.post("${path}/reg/regUsr?r" + Math.random(), {code: $("#loginCapche").val()}, function (data) {
            if (data) {
                if (data == "success") {
                    alert("注册成功，请登录邮箱查看激活邮件进行激活");
                } else {
                    alert(data);
                }
            }
        });
    }
</script>
</body>
</html>
